#ifndef _MIXP_MODULE_MANAGER_H
#define _MIXP_MODULE_MANAGER_H

#include "mixedprocess.h"
#include "mixp_module.h"

#define MAX_FLOW_STEPS (8)

#ifdef __cplusplus
extern "C"
{
#endif
    typedef struct mixp_module mixp_module_t;

    typedef struct mixp_module_manager
    {
        mixp_config_t *config;
        struct list_head modules;
        mixp_module_t *flow[MAX_FLOW_STEPS];
    } mixp_module_manager_t;

    mixp_module_manager_t *mixp_module_manager_new(mixp_config_t *);
    void mixp_module_manager_free(mixp_module_manager_t *);
    mixp_module_t *module_lookup_by_name(mixp_module_manager_t *, const char *);
    mixp_module_t *module_lookup_by_type(mixp_module_manager_t *, int);

#define CALL(module, fn, ...) \
    ({__typeof__(fn) *sym = (__typeof__(fn) *)            \
                            dlsym(module->handle, #fn);   \
     sym(__VA_ARGS__); })

#ifdef __cplusplus
};
#endif
#endif